import pygame
import sys

# 初始化 Pygame
pygame.init()

# 设置窗口大小
screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption("Simple Game")

# 设置颜色
WHITE = (255, 255, 255)
RED = (255, 0, 0)

# 设置初始位置
x, y = 400, 300

# 游戏循环
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    # 获取按键状态
    keys = pygame.key.get_pressed()
    if keys[pygame.K_LEFT]:
        x -= 5
    if keys[pygame.K_RIGHT]:
        x += 5
    if keys[pygame.K_UP]:
        y -= 5
    if keys[pygame.K_DOWN]:
        y += 5

    # 填充背景色
    screen.fill(WHITE)

    # 绘制一个矩形
    pygame.draw.rect(screen, RED, (x, y, 50, 50))

    # 更新屏幕
    pygame.display.flip()

# 退出 Pygame
pygame.quit()
sys.exit()